use serde::Deserialize;

/// Redis链接配置
#[derive(Debug, Deserialize)]
pub struct RedisConfig {
    host: Option<String>,
    port: Option<u16>,
    user: Option<String>,
    password: Option<String>,
    db: Option<i64>,
}

impl RedisConfig {
    pub fn host(&self) -> &str { &self.host.as_deref().unwrap_or("localhost") }
    pub fn port(&self) -> u16 { self.port.unwrap_or(6379) }
    pub fn user(&self) -> &str { &self.user.as_deref().unwrap_or("default") }
    pub fn password(&self) -> &str { &self.password.as_deref().unwrap_or("default") }
    pub fn db(&self) -> i64 { self.db.unwrap_or(1) }
}